<template>
	<view>

		<map class="map" @click="navigateTo" data-url="/subPages/map/map" :enable-zoom="true" :enable-scroll="true"
			:latitude="latitude" :longitude="longitude" :polyline="polyline">
		</map>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				latitude: 39.909,
				longitude: 116.39742,
				covers: [{
					latitude: 39.909,
					longitude: 116.39742,
					iconPath: '../../static/images/other/local.png'
				}], //地图标志位置
				polyline: [{
					points: [],
					color: '#FF0000DD',
					width: 4,
					colorList: ['#FF0000DD', '#34850a', '#0a8585', '#1d0a85'],
					arrowLine: true

				}]
			}
		},

		methods: {
			onShow() {
				this.getData();

				this.getLocation();
			},
			getData() {
				uni.request({
					url: 'http://175.27.169.196:8081/api/path/020231225002', //仅为示例，并非真实接口地址。
					data: {
						text: 'uni.request'
					},
					header: {},
					success: (res) => {
						console.log(res.data.data);
						this.latitude = res.data.data[0].latitude;
						this.longitude = res.data.data[0].longitude;
						this.polyline[0].points = res.data.data;

						this.covers[0].latitude = res.data.data[0].latitude;
						this.covers[0].longitude = res.data.data[0].longitude;
					}
				});
			},

			// 获取位置
			getLocation() {
				uni.request({
					url: 'https://apis.map.qq.com/ws/coord/v1/translate?locations=39.12,116.83;30.21,115.43&type=3&key=XBKBZ-I7ECZ-MV5XV-Z5PUG-6J3H5-U4FOI', //仅为示例，并非真实接口地址。
					data: {
						text: 'uni.request'
					},
					header: {},
					success: (res) => {
						console.log(res.data.data);
						// this.polyline[0].points = res.data.data;
					}
				});

			},
		}
	}
</script>

<style>
	.map {
		width: 100vw;
		height: 100vh;
	}
</style>